package com.example.concurrency.controller;

import com.example.concurrency.po.User;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * 并发工具的使用测试
 *
 * @author 文希
 * @create 2019-05-10 22:38
 */
@Controller
@RequestMapping("/zw")
@Slf4j
public class TestController {

    @RequestMapping(value = "test",method = RequestMethod.GET)
    @ResponseBody
    public List<User> test(){
        log.info("ok");
        User u1 = new User(1,"1","1");
        User u2 = new User(2,"1","1");
        User u3 = new User(3,"1","1");
        User u4 = new User(4,"1","1");
        User u5 = new User(5,"1","1");
        return Lists.newArrayList(u1,u2,u3,u4,u5);
    }



    @RequestMapping("index")
    public String index(Model model){
        User u1 = new User(1,"1","1");
        User u2 = new User(2,"1","1");
        User u3 = new User(3,"1","1");
        User u4 = new User(4,"1","1");
        User u5 = new User(5,"1","1");
        ArrayList<User> users = Lists.newArrayList(u1, u2, u3, u4, u5);
        model.addAttribute("users",users);
        return "update";
    }
}
